package com.tealer.myapplication;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.tealer.myapplication.databinding.ActivityDataStructureLayoutBinding;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Stack;

/**
 * 描述
 *
 * @author Created by lipengbo
 * @email 1162947801@qq.com
 * @time Created on 2023/2/24 22:37
 */
public class DataStructureActivity extends AppCompatActivity {

    private String TAG=DataStructureActivity.class.getSimpleName();
    private ActivityDataStructureLayoutBinding binding;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding=ActivityDataStructureLayoutBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());



        binding.btnArrayQueue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Deque<String> stack=new ArrayDeque<>();
//                for (int i=0;i<16;i++){
//                    stack.add("李明"+i);
//                }
//                stack.addLast("朋波");
//                while (!stack.isEmpty()){
//                    Log.v(TAG,stack.poll());
//                }

                Stack<String> stack=new Stack<>();
                for (int i=0;i<16;i++){
                    stack.push("李明"+i);
                }
                while (!stack.isEmpty()){
                    Log.v(TAG,stack.pop());
                }

            }
        });
    }


    @Override
    protected void onResume() {
        super.onResume();
        MyApplication.instance=DataStructureActivity.this;
    }

    @Override
    protected void onStop() {
        super.onStop();
        MyApplication.instance=null;
    }
}
